package pers.chao.boxing.core;

import org.springframework.boot.context.properties.ConfigurationProperties;
import pers.chao.tool.date.EasyDateFormat;

/**
 * Description: 响应时间戳属性设置
 *
 * @author W.Chao
 * @date 2020/11/1 21:59
 **/
@ConfigurationProperties(prefix = "response.plugin.timestamp")
public class TimestampPlug {
	/**
	 * 响应时间戳开关
	 */
	private Boolean enable = false;

	/**
	 * 时间戳格式，简写模式或完整模式
	 * yyyyMMddHHmmss -> yyyy-MM-dd HH:mm:ss
	 * yyyyMMdd -> yyyy-MM-dd
	 * HHmmss -> HH:mm:ss
	 * yyyyMMddHHmm -> yyyy-MM-dd HH:mm
	 * yyyyMMddHHmmssSSS -> yyyy-MM-dd HH:mm:ss.SSS
	 */
	private String pattern = EasyDateFormat.defaultPattern();

	public Boolean getEnable() {
		return enable;
	}

	public String getPattern() {
		if (this.pattern.contains("-") || this.pattern.contains(":")) {
			return this.pattern;
		}
		return EasyDateFormat.convertPattern(this.pattern);
	}

	public void setEnable(Boolean enable) {
		this.enable = enable;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}
}
